package org.jeecg.modules.demo.shenhe.service.impl;

import cn.hutool.core.util.StrUtil;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.demo.shenhe.entity.HywyReportProcessApproveRecord;
import org.jeecg.modules.demo.shenhe.mapper.HywyReportProcessApproveRecordMapper;
import org.jeecg.modules.demo.shenhe.service.IHywyReportProcessApproveRecordService;
import org.jeecg.modules.demo.summary.entity.MonthlySummary;
import org.jeecg.modules.demo.summary.service.IMonthlySummaryService;
import org.jeecg.modules.system.entity.SysRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * @Description: hywy_report_process_approve_record
 * @Author: jeecg-boot
 * @Date:   2024-04-08
 * @Version: V1.0
 */
@Service
public class HywyReportProcessApproveRecordServiceImpl extends ServiceImpl<HywyReportProcessApproveRecordMapper, HywyReportProcessApproveRecord> implements IHywyReportProcessApproveRecordService {

    @Override
    public void addShenheJilu(LoginUser user, MonthlySummary monthlySummary,SysRole roleOfUser) {
        HywyReportProcessApproveRecord hywyReportProcessApproveRecord = new HywyReportProcessApproveRecord();
        String roleName = roleOfUser.getRoleName();
        //设置审核业务ID
        hywyReportProcessApproveRecord.setBusinessKey(monthlySummary.getId());
        //设置阶段
        hywyReportProcessApproveRecord.setTaskName(roleName+"发起审核");
        //设置审批结果
        hywyReportProcessApproveRecord.setApproveResult("Y");
        //设置审批人
        hywyReportProcessApproveRecord.setApprover(user.getId());
        //设置审核备注
        if (StrUtil.isNotEmpty(monthlySummary.getRemark())){
            hywyReportProcessApproveRecord.setRemark(monthlySummary.getRemark());
        }
        //保存记录
        super.save(hywyReportProcessApproveRecord);

    }

    @Override
    public void addShenheJilu2(LoginUser user, MonthlySummary monthlySummary, SysRole roleOfUser) {
        HywyReportProcessApproveRecord hywyReportProcessApproveRecord = new HywyReportProcessApproveRecord();
        String roleName = roleOfUser.getRoleName();
        //设置审核业务ID
        hywyReportProcessApproveRecord.setBusinessKey(monthlySummary.getId());
        //设置阶段
        if (monthlySummary.getPass().equals("Y")){
            hywyReportProcessApproveRecord.setTaskName(roleName+"发起审核");
            //设置审批结果
            hywyReportProcessApproveRecord.setApproveResult("Y");
        }else {
            hywyReportProcessApproveRecord.setTaskName(roleName+"审核不通过");
            //设置审批结果
            hywyReportProcessApproveRecord.setApproveResult("N");
        }
        //设置审核备注
        if (StrUtil.isNotEmpty(monthlySummary.getRemark())){
            hywyReportProcessApproveRecord.setRemark(monthlySummary.getRemark());
        }
        //设置审批人
        hywyReportProcessApproveRecord.setApprover(user.getId());
        //保存记录
        super.save(hywyReportProcessApproveRecord);
    }

    @Override
    public void addShenheJilu3(LoginUser user, MonthlySummary monthlySummary, SysRole roleOfUser) {
        HywyReportProcessApproveRecord hywyReportProcessApproveRecord = new HywyReportProcessApproveRecord();
        String roleName = roleOfUser.getRoleName();
        //设置审核业务ID
        hywyReportProcessApproveRecord.setBusinessKey(monthlySummary.getId());
        //设置阶段

        hywyReportProcessApproveRecord.setTaskName(roleName+"进行推送");
        //设置审批结果
        hywyReportProcessApproveRecord.setApproveResult("Y");
        //设置审核备注
        if (StrUtil.isNotEmpty(monthlySummary.getRemark())){
            hywyReportProcessApproveRecord.setRemark(monthlySummary.getRemark());
        }
        //设置审批人
        hywyReportProcessApproveRecord.setApprover(user.getId());
        //保存记录
        super.save(hywyReportProcessApproveRecord);
    }

    @Override
    public void addShenheJilu4(LoginUser user, MonthlySummary monthlySummary, SysRole roleOfUser) {
        HywyReportProcessApproveRecord hywyReportProcessApproveRecord = new HywyReportProcessApproveRecord();
        String roleName = roleOfUser.getRoleName();
        //设置审核业务ID
        hywyReportProcessApproveRecord.setBusinessKey(monthlySummary.getId());
        //设置阶段
        hywyReportProcessApproveRecord.setTaskName(roleName+"已取消审核");
        //设置审批结果
        hywyReportProcessApproveRecord.setApproveResult("Y");
        //设置审批人
        hywyReportProcessApproveRecord.setApprover(user.getId());
        //保存记录
        super.save(hywyReportProcessApproveRecord);
    }
}
